package com.techysky.repository;

import java.io.Serializable;
import java.util.List;

import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.transaction.annotation.Transactional;

import com.techysky.entity.MaintPlan;

public interface MaintPlanRepository extends CoreRepository<MaintPlan, Serializable> {


	@Query(value="select distinct new MaintPlan(mp.limitCond) from MaintPlan mp where mp.projectId=?1")
	List<MaintPlan> findByProjectId(String projectId);
	/**
	 * 只存在一个项目情况下，查询所有
	 * @return
	 */
	@Query(value="select distinct new MaintPlan(mp.limitCond) from MaintPlan mp")
	List<MaintPlan> findAllLimit();
	/**
	 * 设置开始时间
	 * @return
	 */
	@Modifying
	@Transactional
	@Query(value="update MaintPlan mp set mp.createDate=?2 where mp.id=?1")
	public void updateTime(String id, String createDate);
	/**
	 * 查询维修间隔期不为空的所有
	 * @return
	 */
	@Query(value="select * from  sys_maint_plan  t where NOT t.limit_cond='null'", nativeQuery = true)
	List<MaintPlan> findAll1();
}
